﻿cmake_minimum_required(VERSION 2.8)
project(freetype)
file(GLOB_RECURSE lib_hdrs RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} include/*.h)
set(CMAKE_DEBUG_POSTFIX "D")
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
set(lib_srcs 
  src/autofit/autofit.c
  src/base/ftbase.c
  src/base/ftbbox.c
  src/base/ftbdf.c
  src/base/ftbitmap.c
  src/base/ftcid.c
  src/base/ftfntfmt.c
  src/base/ftfstype.c
  src/base/ftgasp.c
  src/base/ftglyph.c
  src/base/ftgxval.c
  src/base/ftinit.c
  src/base/ftlcdfil.c
  src/base/ftmm.c
  src/base/ftotval.c
  src/base/ftpatent.c
  src/base/ftpfr.c
  src/base/ftstroke.c
  src/base/ftsynth.c
  src/base/ftsystem.c
  src/base/fttype1.c
  src/base/ftwinfnt.c
  src/bdf/bdf.c
  src/bzip2/ftbzip2.c
  src/cache/ftcache.c
  src/cff/cff.c
  src/cid/type1cid.c
  src/gzip/ftgzip.c
  src/lzw/ftlzw.c
  src/pcf/pcf.c
  src/pfr/pfr.c
  src/psaux/psaux.c
  src/pshinter/pshinter.c
  src/psnames/psnames.c
  src/raster/raster.c
  src/sfnt/sfnt.c
  src/smooth/smooth.c
  src/truetype/truetype.c
  src/type1/type1.c
  src/type42/type42.c
  src/winfonts/winfnt.c
  src/winfonts/winfnt.c
  src/base/ftdebug.c
)
list(APPEND lib_libs ${ZLIB_LIBRARIES} ${LIBBZ2_LIBRARIES} ${LIBPNG_LIBRARIES})
include_directories(${ZLIB_INCLUDE_DIRS} ${LIBBZ2_INCLUDE_DIR} ${LIBPNG_INCLUDE_DIR} include)
add_definitions(/DFT2_BUILD_LIBRARY)
add_library(${PROJECT_NAME} SHARED ${lib_srcs}  ${lib_hdrs})
target_link_libraries(${PROJECT_NAME} ${lib_libs})
install(DIRECTORY include/ DESTINATION include/freetype2 PATTERN "internal" EXCLUDE)
install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}-targets RUNTIME DESTINATION bin ARCHIVE DESTINATION lib)
install(EXPORT ${PROJECT_NAME}-targets DESTINATION lib/cmake FILE ${PROJECT_NAME}-config.cmake)

if(BUILD_STATIC)
  add_library(${PROJECT_NAME}S STATIC ${lib_srcs})
  install(TARGETS ${PROJECT_NAME}S EXPORT ${PROJECT_NAME}S-targets RUNTIME DESTINATION bin ARCHIVE DESTINATION lib)
  install(EXPORT ${PROJECT_NAME}S-targets DESTINATION lib/cmake FILE ${PROJECT_NAME}S-config.cmake)
endif()
